package com.codeoss.framework.pagebean;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.codeoss.framework.context.YunContext;
import com.codeoss.framework.view.clientscript.ClientPageOpenClickScript;
import com.codeoss.framework.view.pagebean.ListViewPageBean;
import com.codeoss.module.ir.model.IrWorkflow;
import com.codeoss.module.ir.service.IIrWorkflowService;

@Service
public class WorkflowListPagePageBean extends ListViewPageBean{
	@Autowired
	private IIrWorkflowService irWorkflowService;
	public void doDesign() {
		YunContext yunContext=YunContext.getCurrentContext();
		yunContext.setRenderCompleted(true);
		List<Long> idList=getSelectedKeyValueList();
		if(idList==null || idList.size()==0) {
			throw new RuntimeException("请选择项");
		}
		IrWorkflow irWorkflow=irWorkflowService.getById(idList.get(0));
		ClientPageOpenClickScript clientPageOpenClickScript=new ClientPageOpenClickScript();
		yunContext.addClientScript(clientPageOpenClickScript);
		clientPageOpenClickScript.setName(irWorkflow.getName());
		clientPageOpenClickScript.setPageCode("workflow-designer");
		clientPageOpenClickScript.setEnv(ClientPageOpenClickScript.ENV_DEV);
		Map<String,Object> paraMap=new HashMap<String,Object>();
		clientPageOpenClickScript.setParaMap(paraMap);
		paraMap.put("code", irWorkflow.getCode());
		
	}
}
